<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
layout:decorator="layout">
<head>
    <title>修改密码</title>
    <script type="text/javascript">
	/*<![CDATA[*/
		$(function() {
			setMenu("修改密码", true);
			$('#getPwdTelCode').on('click', function() {
				if($('#getPwdTelCode').data('isCount')) return;
				var phone = $('#pwdTel').val();
				$.post('conf-pass_code',{phone: phone});
				pwdCountTime();
			});
			var mPwdCount = 60;
			/*倒计时*/
			function pwdCountTime() {
				mPwdCount--;
				$('#getPwdTelCode').data('isCount', true);
				$('#getPwdTelCode').css('color','#FFFF');
				if(mPwdCount <= 0) {
					$('#getPwdTelCode').data('isCount', false);
					$('#getPwdTelCode').val('重新获取');
					mPwdCount = 60;
					return;
				}
				$('#getPwdTelCode').val(mPwdCount + 's重新获取');
				setTimeout(arguments.callee, 1000);
			};
			$("#pwdTelNowCode").blur(function(){
				var str = $('#pwdTelNowCode').val();
				var reg = /^(?![0-9]+$)(?![a-zA-Z]+$)(?!([^(0-9a-zA-Z)]|[\(\)])+$)([^(0-9a-zA-Z)]|[\(\)]|[a-zA-Z]|[0-9]){6,}$/;
				if(!reg.test(str)){
					$('.form-group-tip').css("display","none");
					$('.form-group-tip1').css("display","block");
					$('.form-group-tip1').css("color","#FF6121");
				}else{
					$('.form-group-tip').css("display","block");
					$('.form-group-tip1').css("display","none");
				}
				if($('.form-group-tip1').css('display')=='block' || $('.form-group-tip2').css('display')=='block'){
					$('.input-submit-02').attr("disabled",true);
				}else{
					$('.input-submit-02').attr("disabled",false);
				}
			});
			$("#pwdTelNowCodeAgain").blur(function(){
				var str1 = $('#pwdTelNowCode').val();
				var str2 = $('#pwdTelNowCodeAgain').val();
				if(str1!=str2){
					$('.form-group-tip2').css("display","block");
				}else{
					$('.form-group-tip2').css("display","none");
				}
				if($('.form-group-tip1').css('display')=='block' || $('.form-group-tip2').css('display')=='block'){
					$('.input-submit-02').attr("disabled",true);
				}else{
					$('.input-submit-02').attr("disabled",false);
				}
			});
			$('.input-submit-02').on('click',function(e){
				var psd1 = $('#pwdTelNowCode').val();
				var psd2 = $('#pwdTelNowCodeAgain').val();
				if(psd1!=psd2){
					$('.form-group-tip2').css("display","block");
					return;
				}
				var code1 = $('#pwdTelCode').val();
				$.ajax({
	                url:"save_password",
	                type:"post",
	                data:{
	                	password:psd1,
	                	code:code1
	                	},
	                success:function(e){
	        			alert("密码修改成功!");
	        		    location.href="../login";
	                },
	                error:function(e){
	                	alert("密码修改失败，请重新填写!");
	                	location.href="../acc/pwd";
	                }
	            });  
			});

			$('.changecolor').focus(function() {
	      	    $(this).css('border-color', '#FF6121');
	      	  }).blur(function() {
	      	    $(this).css('border-color', '');
	      	  });
		})
	/*]]>*/
	</script>
</head>
<body>
<div layout:fragment="content">
	<div class="detail">
	<div class="form-background" id="accountHtml">
		<div class="receivable-setting-item">
			<p style="font-size:18px;padding:20px;"><!-- 修改密码 --></p>
			<!-- <form id="pwd-form" action="javascript:submitData('pwd-form', 'save_password', 'post', null, subSuccess)"> -->
			<form id="pwd-form" >
				<div class="form-group">
					<label for="pwdTel"  class="form-label-new">绑定手机号：</label>
					<input type="text" readonly="readonly" th:value="${data.phone}" id="pwdTel" class="input-newlarge changecolor" placeholder=""/>
				</div>
				<div class="form-group">
					<label class="form-label-new">短信验证码：</label>
					<input type="text" id="pwdTelCode" name="code"  class="input-new changecolor" placeholder=""/>
					<input type="button" id="getPwdTelCode" class="input-get1" value="获取验证码"/>
				</div>
				<div class="form-group">
					<label for="pwdTelNowCode" class="form-label-new ">输入新密码：</label>
					<input type="password" id="pwdTelNowCode" name="password"  class="input-newlarge changecolor"/>
					<div id="passwordTip" class="form-tip-error"></div>
				</div>
				<div class="form-group-tip">请输入6-20位，包含字母、数字、符号中的至少两种</div>
				<div class="form-group-tip1" style="display:none;"><img src="/img/error1.png"/>请输入6-20位，包含字母、数字、符号中的至少两种</div>
				<div class="form-group">
					<label for="pwdTelNowCodeAgain" class="form-label-new">验证新密码：</label>
					<input type="password" id="pwdTelNowCodeAgain" class="input-newlarge changecolor" placeholder=""/>
					<span id="pwdTelNowCodeAgainTip" style="display: inline-block;"></span>
				</div>
				<div class="form-group-tip2" style="display:none;"><img src="/img/error1.png"/>2次密码不一致,请确认</div>
				<div class="form-group">
					<label class="form-label-new"></label>
					<input type="button" value="确认提交" class="input-submit-02"/>
				</div>
			</form>
		</div>
		</div>
	</div>
</div>
</body>
</html>